<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
import {getCourseCapacity} from '@/api/province_jsc';
const animationDuration = 3000
const emphasisStyle = {
    itemStyle: {
        barBorderWidth: 1,
        shadowBlur: 10,
        shadowOffsetX: 0,
        shadowOffsetY: 0,
        shadowColor: 'rgba(0,0,0,0.5)'
    }
};
export default {
  mixins: [resize],
  props: {
    listQuery:{
      type:Object
    },
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '300px'
    }
  },
  data() {
    return {
      showbtns: false,
      chart: null,
      xData:["2020年1","2020年2",'2020年3','2020年4','2020年5','2020年6','2020年7','2020年8','2020年9','2020年10'],
      yData:['78','0','0','0','17','22','46','2','0','0',]
    }
  },
  mounted() {
   
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
 methods: {
      handleClose(){
      this.editDisabled = false;
    },
   getList(){
      this.$nextTick(() => {
      this.initChart()
    })
    //  getCourseCapacity(this.listQuery).then(res=>{
    //     this.xData = res.data.data.map(function (obj, index, array) {
    //       var rObj = [];
    //       rObj = obj.month;
    //       return rObj;
    //     });
    //     this.yData = res.data.data.map(function (obj, index, array) {
    //       var rObj2 = [];

    //       rObj2 = obj.capacity;
    //       return rObj2;
    //     });
    //     this.$nextTick(() => {
    //   this.initChart()
    // })
    //  })
   },
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption({
        tooltip: {
          trigger: 'axis',
          axisPointer: { // 坐标轴指示器，坐标轴触发有效
            type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        
         legend: {
          top: '-5',
        data: ['交付时长(小时)']
    },
        grid: {
          top: 40,
          left: '2%',
          right: '2%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [{
          type: 'category',
          data: this.xData,
          axisTick: {
            alignWithLabel: false
          }
        }],
        yAxis: [{
         
          type: 'value',
          axisTick: {
            show: false
          }
        }],
        series: [{
          name: '交付时长(小时)',
               type: 'line',
            symbolSize:10,
                emphasis: emphasisStyle,
            label:{
            show:true,
            color:'#52A8FEFF'
        },
          lineStyle:{
            color:'#FFCF5AFF'
        },
          stack: 'vistors',
           
            barWidth:'60px',
          data: this.yData,
          animationDuration
        }]
      })
    }
  }
}
</script>
